package com.loveprogrammer.model.goods;

import com.loveprogrammer.engine.enums.EquipmentEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0.0
 * @description: 装备的装备
 * @author: eric
 * @date: 2022-08-11 16:59
 **/
@Data
public class Equips implements Serializable {

    public  String string ="\t\t\t\t\t\t\t\t\t";

    public  String tt ="\t\t";

    private List<Equipment> all;

    public Equips(){
        all = new ArrayList<>();
    }

    public Equips(String string, Equipment weapon, Equipment leftRing, Equipment rightRing, Equipment breastplate, Equipment shoes,
                  Equipment helmet, Equipment glove, Equipment necklace, Equipment legArmor, Equipment belt, Equipment barcer,
                  Equipment shoulder, Equipment shield) {
        all = new ArrayList<>();
        this.string = string;
        this.weapon = weapon;
        this.leftRing = leftRing;
        this.rightRing = rightRing;
        this.breastplate = breastplate;
        this.shoes = shoes;
        this.helmet = helmet;
        this.glove = glove;
        this.necklace = necklace;
        this.legArmor = legArmor;
        this.belt = belt;
        this.barcer = barcer;
        this.shoulder = shoulder;
        this.shield = shield;
        initAll();
    }

    private void initAll() {
        if(weapon != null){
            all.add(weapon);
        }
        if(leftRing != null){
            all.add(leftRing);
        }
        if(leftRing != null){
            all.add(leftRing);
        }
        if(breastplate != null)
            all.add(breastplate);
        if(shoes != null)
            all.add(shoes);
        if(helmet != null)
            all.add(helmet);
        if(glove != null)
            all.add(glove);

        if(necklace != null)
            all.add(necklace);
        if(legArmor != null)
            all.add(legArmor);

        if(belt != null)
            all.add(belt);
        if(barcer != null)
            all.add(barcer);

        if(shoulder != null)
            all.add(shoulder);
        if(shield != null)
            all.add(shield);
    }

    // 装备的武器
    private Equipment weapon;

    // 装备的戒指 左戒
    private Equipment leftRing;

    // 装备的戒指 右戒
    private Equipment rightRing;

    // 装备的护甲
    private Equipment breastplate;

    // 装备的鞋
    private Equipment shoes;

    // 装备的头盔
    private Equipment helmet;

    // 装备的手套
    private Equipment glove;

    // 装备的项链
    private Equipment necklace;

    // 装备的腿甲
    private Equipment legArmor;

    // 装备的腰带
    private Equipment belt;

    // 装备的护壁
    private Equipment barcer;

    // 装备的肩甲
    private Equipment shoulder;

    // 装备的盾牌
    private Equipment shield;

    public String prettyPrint() {
        return  string+"****装备信息**********************************************************\n"+
                tt + "武器：" + (getWeapon() == null ? "无" : getWeapon().toString()) +"\n"+
                tt + "盾牌：" + (getShield() == null ? "无" : getShield().toString()) +"\n"+
                tt + "胸甲：" + (getBreastplate() == null ? "无" : getBreastplate().toString()) +"\n"+
                tt + "头盔：" + (getHelmet() == null ? "无" : getHelmet().toString()) +"\n"+
                tt + "肩甲：" + (getShoulder() == null ? "无" : getShoulder().toString()) +"\n"+
                tt + "护壁：" + (getBarcer() == null ? "无" : getBarcer().toString()) +"\n"+
                tt + "手套：" + (getGlove() == null ? "无" : getGlove().toString()) +"\n"+
                tt + "腰带：" + (getBelt() == null ? "无" : getBelt().toString()) +"\n"+
                tt + "腿甲：" + (getLegArmor() == null ? "无" : getLegArmor().toString()) +"\n"+
                tt + "鞋子：" + (getShoes() == null ? "无" : getShoes().toString()) +"\n"+
                tt + "左戒：" + (getLeftRing() == null ? "无" : getLeftRing().toString()) +"\n"+
                tt + "右戒：" + (getRightRing() == null ? "无" : getRightRing().toString()) +"\n"+
                tt + "项链：" + (getNecklace() == null ? "无" : getNecklace().toString()) +"\n"+
                string+""+"************************************************************";
    }

    public Equipment findByPosition(EquipmentEnum equipmentEnum){
        if(equipmentEnum.equals(EquipmentEnum.WEAPON))
            return this.getWeapon();
        if(equipmentEnum.equals(EquipmentEnum.BARCER))
            return this.getBarcer();
        if(equipmentEnum.equals(EquipmentEnum.BELT))
            return this.getBelt();
        if(equipmentEnum.equals(EquipmentEnum.BREASTPLATE))
            return this.getBreastplate();
        if(equipmentEnum.equals(EquipmentEnum.GLOVES))
            return this.getGlove();
        if(equipmentEnum.equals(EquipmentEnum.HELMET))
            return this.getHelmet();
        if(equipmentEnum.equals(EquipmentEnum.LEFTRING))
            return this.getLeftRing();
        if(equipmentEnum.equals(EquipmentEnum.LEGARMOR))
            return this.getLegArmor();
        if(equipmentEnum.equals(EquipmentEnum.NECKLACE))
            return this.getNecklace();
        if(equipmentEnum.equals(EquipmentEnum.RIGHTRING))
            return this.getRightRing();
        if(equipmentEnum.equals(EquipmentEnum.SHIELD))
            return this.getShield();
        if(equipmentEnum.equals(EquipmentEnum.SHOES))
            return this.getShoes();
        if(equipmentEnum.equals(EquipmentEnum.SHOULDER))
            return this.getShoulder();
        return null;
    }


    public List<Equipment> getAll() {
        return all;
    }
}
